package com.easy.query.processor.helper;

import com.easy.query.processor.generate.ClassProxyGenerator;

/**
 * create time 2023/11/8 17:08
 * 文件说明
 *
 * @author xuejiaming
 */
public class AptConstant {

    public static final String PROXY_TEMPLATE = "package @{package};\n" +
            "\n" +
            "import com.easy.query.core.expression.parser.core.available.TableAvailable;\n" +
            "import com.easy.query.core.proxy.AbstractProxyEntity;\n" +
            "import com.easy.query.core.proxy.SQLColumn;\n" +
            "@{imports}" +
            "\n" +
            "/**\n" +
            " * this file automatically generated by easy-query, don't modify it\n" +
            " * 当前文件是easy-query自动生成的请不要随意修改\n" +
            " * 如果出现属性冲突请使用@ProxyProperty进行重命名\n" +
            " *\n" +
            " * @author easy-query\n" +
            " */\n" +
            "public class @{entityClassProxy} extends AbstractProxyEntity<@{entityClassProxy}, @{entityClass}> {\n" +
            "\n" +
            "    private static final Class<@{entityClass}> entityClass = @{entityClass}.class;\n" +
            "\n" +
            "    public static final @{entityClassProxy} TABLE = createTable().createEmpty();" +
            "\n" +
            "    public static @{entityClassProxy} createTable() {\n" +
            "        return new @{entityClassProxy}();\n" +
            "    }\n" +
            "\n" +
            "    public @{entityClassProxy}() {\n" +
            "    }\n" +
            "\n" +
            "    @{fieldContent}" +
            "\n" +
            "    @Override\n" +
            "    public Class<@{entityClass}> getEntityClass() {\n" +
            "        return entityClass;\n" +
            "    }\n" +
            "\n" +
            "    @{valueObjectContext}\n" +
            "\n" +
            "    @{selectorContext}\n" +
            "\n" +
            "\n" +
            "\n" +
            "    public static final class Fields {\n" +
            "@{fieldStaticContext}" +
            "\n" +
            "        private Fields() {\n" +
            "        }\n" +
            "    }" +
            "\n" +
            "}";



    public static final String FIELD_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public @{SQLColumn}<@{entityClassProxy}> @{proxyProperty}(){\n" +
            "        return @{sqlColumnMethod}(\"@{property}\");\n" +
            "    }";
    public static final String ANY_FIELD_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public @{SQLColumn}<@{entityClassProxy},@{propertyType}> @{proxyProperty}(){\n" +
            "        return @{sqlColumnMethod}(\"@{property}\",@{propertyTypeClass});\n" +
            "    }";

    public static final String FIELD_NAVIGATE_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public @{propertyProxy} @{proxyProperty}(){\n" +
            "        return getNavigate(\"@{property}\",new @{propertyProxy}());\n" +
            "    }";
    /**
     * SQLQueryable<MySchoolStudentProxy, MySchoolStudent>
     */
    public static final String FIELD_NAVIGATES_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public SQLManyQueryable<@{entityClassProxy},@{propertyProxy},@{propertyType}> @{proxyProperty}(){\n" +
            "        return getNavigateMany(\"@{property}\",new @{propertyProxy}());\n" +
            "    }";
    public static final String FIELD_VALUE_OBJECT_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public @{entityClass}Proxy @{proxyProperty}() {\n" +
            "        return getValueObject(new @{entityClass}Proxy(getEntitySQLContext(),getTable(), getValueProperty(\"@{property}\")));\n" +
            "    }";


    public static final String FIELD_VALUE_OBJECT_CLASS_TEMPLATE = "\n" +
            "    public static class @{entityClass}Proxy extends AbstractValueObjectProxyEntity<@{mainEntityClassProxy}, @{entityClass}> {\n" +
            "\n" +
            "        private @{entityClass}Proxy(EntitySQLContext entitySQLContext,TableAvailable table, String propertyName) {\n" +
            "            super(entitySQLContext,table, propertyName);\n" +
            "        }\n" +
            "\n" +
            "        @{fieldContent}" +
            "\n" +
            "        @{valueObjectContext}" +
            "    }";

    public static final String FIELD_COMMENT_METHOD ="\n" +
            "\n" +
            "     public static String getFieldComment(String property){\n" +
            "         switch (property){\n" +
            "             @{caseContent}\n" +
            "             default:\n" +
            "                 return null;\n" +
            "         }\n" +
            "     }";

    public static final String PROXY_SELECTOR_TEMPLATE =
            "\n" +
            "/**\n" +
            "* 数据库列的简单获取\n" +
            "* @return\n" +
            "*/\n"+
            "public @{selectorName} FETCHER =new @{selectorName}(this,null,SQLSelectAsExpression.empty);\n"+
            "\n" +
            "    public static class @{selectorName} extends AbstractFetcher<@{entityClassProxy},@{entityClass}, @{selectorName}> {\n" +
            "\n" +
            " public @{selectorName}(@{entityClassProxy} proxy, @{selectorName} prev, SQLSelectAsExpression sqlSelectAsExpression) {\n" +
            "            super(proxy, prev, sqlSelectAsExpression);\n" +
            "        }\n" +
            "\n" +
            "        @{fieldSelectorContent}" +
            "\n" +
            "        @Override\n" +
            "        protected @{selectorName} createFetcher(@{entityClassProxy} cp, AbstractFetcher<@{entityClassProxy}, @{entityClass}, @{selectorName}> prev, SQLSelectAsExpression sqlSelectExpression) {\n" +
            "            return new @{selectorName}(cp, this, sqlSelectExpression);\n" +
            "        }"+
            "\n" +
            "    }";
    public static final String FIELD_SELECTOR_PROPERTY_TEMPLATE = "\n" +
            "    @{comment}\n" +
            "    public @{selectorName} @{proxyProperty}() {\n" +
            "            return add(getProxy().@{proxyProperty}());\n" +
            "    }";
    public static final String FIELD_COMMENT_TEMPLATE = "\n" +
            "           case \"@{property}\": return \"@{comment}\";";
    public static final String FIELD_STATIC_TEMPLATE =
            "        public static final String @{property} = \"@{property}\";\n";






    public static final ClassProxyGenerator PROXY_TEMPLATE_GENERATOR =new ClassProxyGenerator(PROXY_TEMPLATE);
    public static final ClassProxyGenerator FIELD_VALUE_OBJECT_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_VALUE_OBJECT_TEMPLATE);
    public static final ClassProxyGenerator FIELD_NAVIGATES_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_NAVIGATES_TEMPLATE);
    public static final ClassProxyGenerator FIELD_NAVIGATE_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_NAVIGATE_TEMPLATE);
    public static final ClassProxyGenerator ANY_FIELD_TEMPLATE_GENERATOR=new ClassProxyGenerator(ANY_FIELD_TEMPLATE);
    public static final ClassProxyGenerator FIELD_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_TEMPLATE);
    public static final ClassProxyGenerator PROXY_SELECTOR_TEMPLATE_GENERATOR=new ClassProxyGenerator(PROXY_SELECTOR_TEMPLATE);
    public static final ClassProxyGenerator FIELD_SELECTOR_PROPERTY_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_SELECTOR_PROPERTY_TEMPLATE);
    public static final ClassProxyGenerator FIELD_VALUE_OBJECT_CLASS_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_VALUE_OBJECT_CLASS_TEMPLATE);
    public static final ClassProxyGenerator FIELD_STATIC_TEMPLATE_GENERATOR=new ClassProxyGenerator(FIELD_STATIC_TEMPLATE);
}
